package org.java.user.api;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;

import java.util.HashMap;
import java.util.Map;
@Configuration
public class PasswordEncoderConfig {
    @Bean
    public PasswordEncoder passwordEncoder(){
        Map<String,PasswordEncoder> passwordEncoderMap = new HashMap<>();
        passwordEncoderMap.put("BCrypt",new BCryptPasswordEncoder());
        passwordEncoderMap.put("SCrypt",new SCryptPasswordEncoder());
        passwordEncoderMap.put("NoOp", NoOpPasswordEncoder.getInstance());
        DelegatingPasswordEncoder passwordEncoder = new DelegatingPasswordEncoder("BCrypt",passwordEncoderMap);
        return passwordEncoder;

    }
}
